from flask import Flask
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
from config import config_dict

db=SQLAlchemy()


def create_app(config_name):
    app = Flask(__name__)


    # 先配置,再设置session
    app.config.from_object(config_dict[config_name])


    # 导入蓝图，注册
    from info.modules.news import new_blue
    app.register_blueprint(new_blue)

    Session(app)
    db.init_app(app)
    return app